/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.img;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;

/**
 * <p>Project: app2022 - Img3
 * <p>Powered by webrx On 2022-01-21 09:09:42
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Img3 {
    public static void main(String[] args) throws Exception {
        //读取图像文件
        var src = ImageIO.read(new File("f.png"));
        var w = src.getWidth();
        var h = src.getHeight();

        //定义了一个灰度图像，在此图像中所有对象都是黑白的，
        var i = new BufferedImage(w, h, 10);
        var g = i.createGraphics();
        //使用画笔将src图像，画黑白图像中，就没有彩色了
        g.drawImage(src, 0, 0, null);
        g.dispose();
        ImageIO.write(i, "png", new File("f2.png"));
        Runtime.getRuntime().exec("cmd /k start f.png");
        Runtime.getRuntime().exec("cmd /k start f2.png");
    }
}
